﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Moqikaka.DAL
{
    using MySql.Data.MySqlClient;
    using System.Data;

    /// <summary>
    /// 其他数据连接基类
    /// </summary>
    public class GameBaseDAL : BaseDAL
    {
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public static String DBConnectionString { get; set; }

        /// <summary>
        /// 执行无返回值的数据库操作，仅返回受影响的行数
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="commandParameters">参数</param>
        /// <returns>受影响的行数</returns>
        protected static Int32 ExecuteNonQuery(String commandText, params MySqlParameter[] commandParameters)
        {
            return ExecuteNonQuery(DBConnectionString, commandText, commandParameters);
        }

        /// <summary>
        /// 执行返回单个值的数据库操作
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="commandParameters">参数</param>
        /// <returns>返回单个值</returns>
        protected static Object ExecuteScalar(String commandText, params MySqlParameter[] commandParameters)
        {
            return ExecuteScalar(DBConnectionString, commandText, commandParameters);
        }

        /// <summary>
        /// 执行数据库操作，返回一个数据表
        /// </summary>
        /// <param name="commandText">sql语句</param>
        /// <param name="commandParameters">参数</param>
        /// <returns>包含结果的数据表</returns>
        protected static DataTable ExecuteDataTable(String commandText, params MySqlParameter[] commandParameters)
        {
            return ExecuteDataTable(DBConnectionString, commandText, commandParameters);
        }
    }
}
